local benshi = fk.CreateSkill{
  name = "wk_heg__benshi",
}

Fk:loadTranslationTable{
  ["wk_heg__benshi"] = "奔矢",
  [":wk_heg__benshi"] = "①你使用的伤害牌额外指定你攻击范围内所有与你势力不同的角色为目标；②其他角色成为你使用黑色牌的目标时，其可以弃置一张类型不同的牌，取消之。",
  ["#wk_heg__benshi-discard"] = "奔矢：你可以弃置一张与此牌类型不同的牌，取消你为此牌的目标",
}

local H = require "packages/ol_hegemony/util"

benshi:addEffect(fk.AfterCardTargetDeclared, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(benshi.name) and data.card.is_damage_card
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = data.tos
    for _, p in ipairs(room.alive_players) do
      if player:inMyAttackRange(p) and not table.contains(targets, p) and not player:isProhibited(p, data.card) and H.compareKingdomWith(player, p, true) then
        room:doIndicate(player, {p})
        data:addTarget(p)
      end
    end
  end,
})

benshi:addEffect(fk.TargetConfirming, {
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(benshi.name) and player:hasShownSkill(benshi.name) and data.card.color == Card.Black and data.from and data.from == player
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local throw_type
    if data.card.type == Card.TypeBasic then
        throw_type = ".|.|.|.|.|trick,equip"
    else
        throw_type = ".|.|.|.|.|basic,equip"
    end
    local card = room:askToDiscard(target, {
        min_num = 1,
        max_num = 1, 
        include_equip = true, 
        skill_name = benshi.name, 
        cancelable = true, 
        pattern = throw_type, 
        prompt = "#wk_heg__benshi-discard",
        skip = true,
    })
    if #card > 0 then
      event:setCostData(self, {card = card})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local card = event:getCostData(self).card
    room:throwCard(card, benshi.name, target, target)
    data:cancelTarget(target)
  end,
})


return benshi